package io.github.biezhi.elves.bidding.model;

import io.github.biezhi.elves.common.MapConstants;
import io.github.biezhi.elves.utils.StringUtils;
import lombok.Data;

/**
 * 公告记录表查询条件
 *
 */
@Data
public class RecordNoticeQuery {
	//当前页码
	private Integer size = 1;
	//每页显示数量
	private Integer pageNo = 100;
	//操作方式(1：下载公告详情html内容；2：解析公告详情html内容，并提取所需字段信息)
	private Integer operationMode;
	//公告类型
	private String noticeType;
	//网站名称
	private String siteName;
	
	public RecordNoticeQuery() {}
	public RecordNoticeQuery(Integer operationMode, String siteName) {
		this.noticeType = "中标公告";
		this.operationMode = operationMode;
		if (MapConstants.SITE_BY_EN_MAP.containsKey(siteName)) {
			siteName = StringUtils.getValueForKey(siteName, MapConstants.SITE_BY_EN_MAP);
		}
		this.siteName = siteName;
	}
	
	public RecordNoticeQuery(Integer size, Integer operationMode, String siteName) {
		this.size = size;
		this.noticeType = "中标公告";
		this.operationMode = operationMode;
		if (MapConstants.SITE_BY_EN_MAP.containsKey(siteName)) {
			siteName = StringUtils.getValueForKey(siteName, MapConstants.SITE_BY_EN_MAP);
		}
		this.siteName = siteName;
	}
	
	public Integer getSize() {
		Integer size = this.size;
		if(size > 0 && this.pageNo > 0) {
			size = (size - 1) * this.pageNo;
			return size;
		}
		return 0;
	}
}